<?php
namespace app\admin\controller;
use controller\BasicAdmin;
use think\Db;
class Adminrecharge extends BasicAdmin{
    public $table = 'recharge';
    public function recharge(){
        list($get, $db) = [$this->request->get(), Db::name($this->table)->alias('a')->join('t_user b','a.uid=b.id','LEFT')->field('a.recharge_type,a.status,a.recharge_num,a.money,a.addtime,b.mobile,b.nickname,b.username')];
        isset($get['tel']) && $get['tel'] !='' ? $db->where(['b.mobile'=>trim($get['tel'])]) : '';
        isset($get['put_type']) && $get['put_type'] !='' ? $db->where(['a.recharge_type'=>$get['put_type']]) : '';
        isset($get['status']) && $get['status'] !='' ? $db->where(['a.status'=>$get['status']]) : '';
        $list = parent::_list($db,1,'','');
        $list['type'] = $recharge_type = [1=>'支付宝',2=>'微信',3=>'银行卡'];
        $list['status'] = $status = [1=>'失败',2=>'成功'];
        foreach ($list['list'] as $key=>$val){
            $list['list'][$key]['recharge_type_name'] = $recharge_type[$val['recharge_type']];
            $list['list'][$key]['status_name'] = $status[$val['status']];
            $list['list'][$key]['addtimes'] = date('Y-m-d H:i:s',$val['addtime']);
        }
        return $this->fetch('', ['title' => '充值列表','list'=>$list]);
    }
}